package com.tianhui.consignortwofei.mvp.model;

import android.content.Context;

import com.fgs.common.CommonModel;
import com.fgs.common.api.CommonConfig;
import com.fgs.common.progress.ObserverResponseListener;
import com.tianhui.consignortwofei.api.OrderApiService;
import com.tianhui.consignortwofei.api.VehicleApiService;
import com.tianhui.consignortwofei.mvp.model.enty.VehicleInfo;

import java.util.Map;

import io.reactivex.ObservableTransformer;

/**
 * @author fgs
 * @date 2020/12/24
 * @description
 **/
public class VehicleModel<T> extends CommonModel<T> implements IDictionaryModel<T> {
    /**
     * 车辆列表
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleListModel(Context context, Map<String, String> map, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleList(map), observerListener, transformer, isDialog, true);
    }
    /**
     * 车辆信息
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleInfoModel(Context context, Map<String, String> map, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleInfo(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 车辆信息保存
     *
     * @param context
     * @param info
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleInfoSaveModel(Context context, VehicleInfo info, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleInfoSave(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 车辆启用/停用
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleStatusModel(Context context, Map<String, String> map, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleStatus(map), observerListener, transformer, isDialog, true);
    }
    /**
     * 车辆信息保存并审核通过
     *
     * @param context
     * @param info
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleInfoSaveAndAuditModel(Context context, VehicleInfo info, boolean isDialog,
                                             ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleInfoSaveAndAudit(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 车辆审核
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void driverAuditModel(Context context, Map<String, String> map, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).vehicleAudit(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 重新生成挂靠声明
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void createStatementModel(Context context, Map<String, String> map, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).createStatement(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 生成道路运输证号获取城市信息
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void getCityInfoModel(Context context, Map<String, String> map, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(VehicleApiService.class).getCityInfo(map), observerListener, transformer, isDialog, true);
    }


    @Override
    public void dictionaryModel(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dictionaryList(map), observerListener, transformer, isDialog, true);

    }
}
